const router = require('koa-router')()
const upload = require('@koa/multer')({dest:'public/upload'});

const userCtrl = require('../controllers/userCtrl')
const annouceCtrl = require('../controllers/annouce')
const newsCtrl = require('../controllers/newsCtrl')
const hospitalCtrl = require('../controllers/hospitalCtrl')
const shopCtrl = require('../controllers/shopCtrl')

// // 图片上传
router.post('/upload-Imgs',  upload.single('imgs'), userCtrl.uploadAppealImgs) // 图片上传uni
router.post('/upload-webImgs',  upload.single('imgs'), (ctx)=>{
  const {filename} = ctx.file
  let path = `/upload/${filename}`
  ctx.body = {
    "errno": 0, // 注意：值是数字，不能是字符串
    "data": {
        "url": path, // 图片 src ，必须
    }
}
}) 

// uni 部分

router.post('/wxlogin', userCtrl.wxlogin)

router.post('/register', userCtrl.wxRegister)

router.post('/usereditinfo', userCtrl.userEditInfo)

router.post('/userheal', userCtrl.userHeal)

router.post('/userappeallist', userCtrl.userAppeal)

router.post('/userupappeal', userCtrl.userUpAppeal)

router.post('/userevo', userCtrl.userEvo)

router.get('/annouce', annouceCtrl.annouce)

router.get('/hspinfo', hospitalCtrl.hspInfo)

router.get('/goodslists', shopCtrl.goodsUNIlist)

router.post('/goodslist', shopCtrl.goodslist)

router.post('/orderlist', shopCtrl.orderlist)

router.post('/deleteorder', shopCtrl.deleteorder)

router.post('/deliverinfo', shopCtrl.deliverInfo)

router.post('/appoimenthsp', hospitalCtrl.appoimentHsp)

router.post('/appoimentStatus', hospitalCtrl.appoimentStatus)

router.post('/cancleappoi', hospitalCtrl.cancleAppoi)

router.get('/newslist', newsCtrl.newslist)

router.post('/newsdetail', newsCtrl.selectNewsDetailMod)



module.exports = router
